package net.ojbk.service;

import net.ojbk.dao.ClassDataDao;

import net.ojbk.po.ClassData;

public class ClasDataService {
	private ClassDataDao classDataDao;
	
	public ClasDataService() {
		classDataDao=new ClassDataDao();
	}
	
	//获取全部班级记录,列表形式返回数据
	public ClassData[] getClasData() {
		ClassData[] cds = classDataDao.queryAllRecord();
		return cds;
	}
	
	//获取某个学校的所有班级记录
	public ClassData[] getClasData(String college) {
		ClassData cd=new ClassData();
		cd.setCollege(college);
		ClassData[] cds = classDataDao.queryCollege(cd);
		return cds;
	}
	
	//获取某个学校某个年级的所有班级记录
	public ClassData[] getClasData(String college,String grade) {
		ClassData cd=new ClassData();
		cd.setCollege(college);
		cd.setGrade(grade);
		ClassData[] cds = classDataDao.queryGrade(cd);
		return cds;
	}
	
	//获取某个学校某个年级的某个班级记录
	public ClassData[] getClasData(String college,String grade,String clas) {
		ClassData cd=new ClassData();
		cd.setCollege(college);
		cd.setGrade(grade);
		cd.setClas(clas);
		ClassData[] cds = classDataDao.queryClas(cd);
		return cds;
	}
	
	//删除某个学校的所有班级记录
	public int deleteClasData(String college) {
		ClassData cd=new ClassData();
		cd.setCollege(college);
		boolean flag= classDataDao.deleteCollege(cd);
		if(flag)  return 1;
		return 2;
	}
	
	//删除某个学校某个年级的所有班级记录
	public int deleteClasData(String college,String grade) {
		ClassData cd=new ClassData();
		cd.setCollege(college);
		cd.setGrade(grade);
		boolean flag = classDataDao.deleteGrade(cd);
		if(flag)  return 1;
		return 2;
	}
	
	//删除某个学校某个年级的某个班级记录
	public int deleteClasData(String college,String grade,String clas) {
		ClassData cd=new ClassData();
		cd.setCollege(college);
		cd.setGrade(grade);
		cd.setClas(clas);
		boolean flag= classDataDao.deleteClas(cd);
		if(flag)  return 1;
		return 2;
	}
	public static void main(String[] args) {
		//ClassDataDao cdd=new ClassDataDao();
		//ClasDataService cds=new ClasDataService();
		//ClassData cd=new ClassData();
		//boolean flag=false;
		/*cd.setClas("161");
		cd.setGrade("16");
		cd.setCollege("thu");
		flag=cdd.addOneRecord(cd);
		cd.setClas("151");
		cd.setGrade("15");
		cd.setCollege("thu");
		flag=cdd.addOneRecord(cd);
		cd.setClas("161");
		cd.setGrade("16");
		cd.setCollege("pku");
		flag=cdd.addOneRecord(cd);*/
		//int t=cds.deleteClasData("thu");
		/*cd.setClas("152");
		cd.setGrade("15");
		cd.setCollege("pku");
		flag=cdd.addOneRecord(cd);*/
		//int t=cds.deleteClasData("pku","16");
		//System.out.println(t);
	}
}
